package com.example.administrator.printoutindemo.bean;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class GetOutStorageReceiver implements Serializable {


    public int id;
    public String name;//姓名
    public String mobile;//电话
    public String company;//单位
    public String department;//部门

    // 将JSON对象转化为list
    public List<GetOutStorageReceiver> getListFromJSON(String JsonStr) {
        List<GetOutStorageReceiver> clist = new ArrayList<GetOutStorageReceiver>();

        try {

            JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

            for (int i = 0; i < jay.length(); i++) {
                JSONObject temp = (JSONObject) jay.get(i);

                GetOutStorageReceiver n = new GetOutStorageReceiver();

                n.setId(Integer.parseInt(temp.getString("id")));
                n.setName(temp.getString("name"));
                n.setMobile(temp.getString("mobile"));
                n.setCompany(temp.getString("company"));
                n.setDepartment(temp.getString("department"));

                clist.add(n);

            }

        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }

        return clist;

    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }
}